package com.example.hdwx.myapplication.json.found_json;

import android.util.Log;

import com.example.hdwx.myapplication.eneity.found_eneitys.FoundShareEneity;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * 发现分享家
 */

public class FoundShareJSON {
    static String TAG="FoundShareJSON";
    public  static List<FoundShareEneity> getFoundS(String response){
        List<FoundShareEneity> dataS = new ArrayList<>();
        try {
            JSONObject object = new JSONObject(response);
            JSONArray array = object.getJSONArray("data");
            for (int i = 0; i < array.length(); i++) {
                FoundShareEneity eneity = new FoundShareEneity();
                JSONObject object1 = array.getJSONObject(i);
                eneity.setNickName(object1.optString("nickName"));
                eneity.setImageUrl(object1.optString("imageUrl"));
                eneity.save();
                if(eneity.save()){
                    Log.e(TAG,"FoundShareJSON数据存储成功");
                }else {
                    Log.e(TAG,"FoundShareJSON数据存储失败");
                }
                dataS.add(eneity);
            }
            return dataS;
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }
}
